package com.zenith.yasoo.setup;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.sun.istack.internal.NotNull;


@Entity
@Table(name="contact_mech_type")
public class ContactMechType {
	private static final long serialVersionUID = 1L;
	
	public static final String TYPE_POSTAL_ADDRESS = "POSTAL_ADDRESS";
	public static final String TYPE_ELECTRONIC_ADDRESS = "ELECTRONIC_ADDRESS";
	public static final String TYPE_TELCOM_NUMBER = "TELCOM_NUMBER";
	
	public ContactMechType() {};
	public ContactMechType(String contactMechTypeCode) {this.contactMechTypeCode=contactMechTypeCode;};
	
	private String contactMechTypeCode;
	private String contactMechTypeName;
	private ContactMechType ParentContactMechTypeCode;
	private String hasTable;
	private Set<ContactMechPurposeType> contactMechPurposes = new LinkedHashSet<ContactMechPurposeType>();
	
	/*------------------------------
	 * getters and annotations
	 --------------------------------*/
	@Id @Column(length=20)
	public String getContactMechTypeCode() {return contactMechTypeCode;}
	
	@Column(length=50) @NotNull
	public String getContactMechTypeName() {return contactMechTypeName;}
	
	@ManyToOne() @JoinColumn(name="parentContactMechTypeCode")
	public ContactMechType getParentContactMechTypeCode() {return ParentContactMechTypeCode;}
	
	@Column(length=1)
	public String getHasTable() {return hasTable;}
	
	@OneToMany(mappedBy = "contactMechType", fetch = FetchType.EAGER)
	public Set<ContactMechPurposeType> getContactMechPurposes() {
		return contactMechPurposes;
	}
	
	public void setContactMechPurposes(
			Set<ContactMechPurposeType> contactMechPurposes) {
		this.contactMechPurposes = contactMechPurposes;
	}
	public void setContactMechTypeCode(String contactMechTypeCode) {
		this.contactMechTypeCode = contactMechTypeCode;
	}
	public void setContactMechTypeName(String contactMechTypeName) {
		this.contactMechTypeName = contactMechTypeName;
	}
	public void setParentContactMechTypeCode(ContactMechType parentContactMechTypeCode) {
		ParentContactMechTypeCode = parentContactMechTypeCode;
	}
	public void setHasTable(String hasTable) {
		this.hasTable = hasTable;
	}	
}
